package com.micro.service.rpc;

import com.micro.service.entity.ResponseMessage;
import com.micro.service.model.UserInfo;
import com.micro.service.rpc.fallback.RpcUserInfoFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Create by Vic Xu on 2019/3/19
 */
@FeignClient(value = "producer-main", fallback = RpcUserInfoFallback.class)
public interface RpcUserInfo {

    @GetMapping(value = "v1/user", produces = {"application/json;charset=UTF-8"})
    public ResponseMessage<List<UserInfo>> getUserInfo();

    @PostMapping(value = "v1/user", produces = {"application/json;charset=UTF-8"})
    public ResponseMessage<UserInfo> saveUserInfo(@RequestBody UserInfo userInfo);

    @PostMapping(value = "v1/user/list", produces = {"application/json;charset=UTF-8"})
    public ResponseMessage<Integer> batchSaveUserInfo(@RequestBody List<UserInfo> userInfos);

    @PutMapping(value = "v1/user", produces = {"application/json;charset=UTF-8"})
    public ResponseMessage<UserInfo> updateUser(@RequestBody UserInfo userInfo);

    @DeleteMapping(value = "v1/user/{id}")
    public ResponseMessage<Integer> deleteUser(@PathVariable("id") String id);
}
